import _http from "@/request/http"

// 引入ts类型
import type { MenuItem } from "./type"

// 枚举接口
enum API {
	// 获取权限菜单
	PERMISSIONMENU_URL = "/admin/acl/permission",
	// 根据角色获取权限菜单
	ROLEPERMISSIONMENU_URL = "/admin/acl/permission/toAssign/",
	// 给角色分配权限
	SETPERMISSION_URL = "/admin/acl/permission/doAssignAcl",
	// 新增菜单
	ADDPERMISSION_URL = "/admin/acl/permission/save",
	// 修改菜单
	EDITPERMISSION_URL = "/admin/acl/permission/update",
	// 删除权限
	DELETEPERMISSION_URL = "/admin/acl/permission/remove/",
}

// 获取权限菜单
export const reqPermissionMenuOrRolePermissionMenu = (
	id: number | undefined,
) => {
	if (id) {
		return _http.get<MenuItem[], any>(API.ROLEPERMISSIONMENU_URL + id)
	} else {
		return _http.get<MenuItem[], any>(API.PERMISSIONMENU_URL)
	}
}
